<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>个人主页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<jsp:include page="../resource.jsp"></jsp:include>
<style>
	body{ height:100%; overflow:auto; }
	.om-panel-body{
	     padding: 1px 3px;
	  }
</style>
<script type="text/javascript">
   var map = null;
   var geocoder = null; //地址解释器
   $(function(){
         $('#tabs').omTabs({
             closable : false,
             height : '99%'
         });
       if($.browser.msie && ($.browser.version == 8.0 || $.browser.version == 9.0)){
    	   var h = $(self.parent.frames['mainFrame']).height()-2; 
    	   $('#tabs').omTabs({height : h});
    	   $('#workBenchMap').css("height",h-50);
       }
       try{
     	if (GBrowserIsCompatible()) {
     	        map= new GMap2(document.getElementById("workBenchMap"));
     	        map.setCenter(new GLatLng(34.161818161230386, 103.798828125), 5); //13为缩放级别，可以通过map.getZoom()获取。
     	        map.enableScrollWheelZoom();
     	        map.disableDoubleClickZoom();
     	        geocoder =  new GClientGeocoder();
     		    map.addControl(new GLargeMapControl());
         }
       
     	$.ajax({
    		url : 'main!findAlarm4map.do',
    		dataType : 'json',
    		success : function(data){
    			for(var i=0 ; i<data.length ; i++){
	    			var point = new GLatLng(data[i].yAxis, data[i].xAxis);
	    			map.addOverlay(createMarker(point, i,data[i]));
    			}
    		}
    	});
     	var baseIcon= new GIcon(G_DEFAULT_ICON);
		baseIcon.shadow= "http://www.google.cn/mapfiles/shadow50.png";
		baseIcon.iconSize= new GSize(20, 34);
		baseIcon.shadowSize= new GSize(17, 34);
		baseIcon.iconAnchor= new GPoint(19, 34);
		baseIcon.infoWindowAnchor= new GPoint(19, 8);
			
     	function createMarker(point, index,data) {
		    var letteredIcon= new GIcon(baseIcon);
		    var content = '';
		    if(data.state == 0){ //离线
		    	letteredIcon.image= "offline.png";
		    	content = "机构："+data.organization+"<br/>设备："+data.objectName
		    }else if(data.state == 1){ //告警
		    	letteredIcon.image= "waring.png";
		    	content = "机构："+data.organization+"<br/>设备："+data.objectName+"<br/>日期 :<b>" + data.dateTime+ "</b></br>内容："+data.alarmContent;
		    }else if(data.state == 2){ //正常
		    	letteredIcon.image= "nomal.png";
		    	content = "机构："+data.organization+"<br/>设备："+data.objectName
		    }
		     
		     markerOptions= { icon:letteredIcon};
		    var marker= new GMarker(point, markerOptions);
			GEvent.addListener(marker, "click", function() {
			   marker.openInfoWindowHtml(content);
			});
		    return marker;
		}

        function refresh(){
      	   map.clearOverlays();
      	   $.ajax({
         		url : 'main!findAlarm4map.do',
         		dataType : 'json',
         		success : function(data){
         			for(var i=0 ; i<data.length ; i++){
      	    			var point = new GLatLng(data[i].yAxis, data[i].xAxis);
      	    			map.addOverlay(createMarker(point, i,data[i]));
         			}
         		}
         	});
         }
     	
        //setInterval(refresh,1000*60);
        
       }catch(e){
    	   console.log(e);
       }  
   });
   
   
        function findLocation(nodeData){
        	var userdataa = nodeData.userData.split(',');
        	if (geocoder) { //只有区域才查找定位到指定地方
        		if(nodeData.id.indexOf('re_') != -1){
	       	  		geocoder.getLatLng(
	       	        		nodeData.text,
	       		            function(point) {
	       		              if (!point) {
	       		            	  $.omMessageBox.alert({content:'没有找到地址：'+nodeData.text});
	       		              } else {
	       		                  map.setCenter(point, 9);
	       		              }
	       		            }
	       	        );
        		}
        	    if(userdataa && userdataa.length > 0){
	        	    if(nodeData.id.indexOf("or_") != -1){
	        			map.setCenter(new GLatLng(userdataa[1], userdataa[0]),11);
	        		}else if(nodeData.id.indexOf("de_") != -1){
	        			map.setCenter(new GLatLng(userdataa[1], userdataa[0]),15);
	        		}else if(nodeData.id.indexOf("te_") != -1){
	        			map.setCenter(new GLatLng(userdataa[1], userdataa[0]),15);
	        		}
        	    }
            }
        }
         
</script>
</head>
 <body onunload="GUnload()">
<div id="tabs" >
    <ul>
       <li><a href="#myworkbench">地图警告信息</a></li>
       <li><a href="totalError.jsp">实时告警监控</a></li>
    </ul>
	<div class="right clear" id="myworkbench">
		  <div id="workBenchMap" style="width: 100%; height: 99%;"></div>
	</div>
</div>


<script type="text/javascript">
	function nav_set(obj,tag_N){
		var nav_list= document.getElementById("nav_list").getElementsByTagName("li");
		var nav_cont=document.getElementById("nav_cont").getElementsByTagName("h1");
		for(var i=0;i<nav_list.length;i++){
			nav_list[i].className="";	
			nav_cont[i].className="cont_tag";
			}
			obj.className="slelcted";
		document.getElementById(tag_N).className="cont_tag_show";
		
		}
</script>

</body>
</html>
